<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<div style="padding: 10px;">
	<form class="op-form" id="editForm" name="editForm" method="post">
		<input type="hidden" name="id" value="${menuEnt.id }">
		<table>
			<tr>
				<td>名称:</td>
				<td>
					<input class="easyui-validatebox" name="name" validType="length[1,100]" value="${menuEnt.name }">
				</td>
			</tr>
			<tr>
				<td>链接地址:</td>
				<td>
					<input class="easyui-validatebox" name="url" required="false" validType="length[2,100]" value="${menuEnt.url }">
				</td>
			</tr>
			<tr>
				<td>排序号:</td>
				<td>
					<input class="easyui-numberbox" name="orderNO" required="true" min="0" value="${menuEnt.orderNO }">
				</td>
			</tr>
			<tr>
				<td>小图标:</td>
				<td>
					<input class="easyui-validatebox" name="icon" required="false" value="${menuEnt.icon }">
				</td>
			</tr>
			<tr>
				<td>状态:</td>
				<td>
					<select id="status" name="status">
						<option value="0">停用</option>
						<option value="1" selected="selected">在用</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>父菜单:</td>
				<td>
					<select id="pid" name="pid" style="width: 206px;"></select>
				</td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td>
					<a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="$('#editForm').submit()">提交</a>
				</td>
				<td>
					<a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="editForm.reset()">重置</a>
					<a href="#" class="easyui-linkbutton" icon="icon-redo" onclick="$('#dataGrid').show();$('#opPanel').panel('close');">返回</a>
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript">

	$(document).ready(function(){
		$('#status option[value='+ ${menuEnt.status} +']').attr('selected', true);
		
		initPMenus();
		
		$('#editForm').form({
			onSubmit:function(){
				if($(this).form('validate')){
					ajaxEdit();
				}else{
					return false;
				}
			}
		});
	});
	
	function initPMenus(){
		$('#pid').combotree({
			url: "menu.action?command=getMenuTree"
		});
		$('#pid').combotree('setValue', '${menuEnt.parent.id}');
	}
	
	function ajaxEdit(){
		var actionURL = "menu.action?command=update";
		var params = jQuery("#editForm").dataForAjax().data;
			
		jQuery.ajax({
			url: actionURL,
			type: "post",
			cache: false,
			data: params,
			success: function(result){
				if("true" == result){
					$.messager.alert("友情提示", "您的操作成功!", "info", function(){
						clearSels();
						setBtn(true);
						$('#tt').datagrid('reload');
						$("#dataGrid").show();
						$('#opPanel').panel('close');
					});
				}else{
					$.messager.alert("友情提示", "您的操作失败!", "error");
				}
			}
		});
	}
	
</script>